/**
 * @file    test_Festival.cpp
 * @brief   Test case for Festival
 *
 * @verbatim

 g++ test_Festival.cpp -I/usr/include -I/usr/include/speech_tools -L/usr/lib -L../lib -L/usr/lib -lFestival -lncurses -lesd -lestools -lestbase -leststring

@endverbatim
 *
 ****************************************************************************
 * @version $Id: test_Festival.cpp 2821 2010-08-01 11:44:26Z alex $
 * @author Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ******************************************************************************/

 #include <string>

 #include <festival/festival.h>


int main()
 {
	int heap_size = 210000;  // default scheme heap size
	int load_init_files = 1; // we want the festival init files loaded
	int ret = 0;

	festival_initialize(load_init_files,heap_size);


	string command = "(voice_ked_diphone)";

	ret = festival_eval_command( command.c_str() );
	printf("festival_eval_command() = %d\n", ret);


	string text;
	string filename;

	text = "hello world";
	filename = "output.wav";

	// Convert to a waveform
	EST_Wave wave;
	ret = festival_text_to_wave( text.c_str(), wave );
	printf("festival_text_to_wave() = %d\n", ret);

	ret = wave.save( filename.c_str(), "riff" );
	printf("wave() = %d\n", ret);









	// festival_say_file puts the system in async mode so we better
	// wait for the spooler to reach the last waveform before exiting
	// This isn't necessary if only festival_say_text is being used (and
	// your own wave playing stuff)
	festival_wait_for_spooler();




	return 0;
 }
